package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.model.hosp.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author:hx
 * @DateTime:2022/11/8 9:27
 * @Description:
 */
@RestController
@RequestMapping("/api/hosp")
public class ApiDepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @PostMapping("/saveDepartment")
    public Result saveDepartment(@RequestParam Map<String,Object> paramMap){
        departmentService.saveDepartment(paramMap);
        return Result.ok();
    }

    @PostMapping("/department/list")
    public Result findDepartment(@RequestParam Map<String,Object> paramMap){

        Page<Department> page = departmentService.findDepartment(paramMap);

        return Result.ok(page);
    }

    @PostMapping("/department/remove")
    public Result removeDepartment(@RequestParam Map<String,Object> paramMap){
        departmentService.removeDepartment(paramMap);
        return Result.ok();
    }
}
